package com.store.controller;

import com.store.domain.R;
import com.store.domain.dto.OrderDto;
import com.store.domain.entity.Order;
import com.store.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author yu
 * @date 2024/6/26
 */
@RestController
@RequestMapping("order")
public class OrderController {
    @Resource
    private OrderService orderService;
    @GetMapping("{pageNum}/{pageSize}")
    public R getPageOrder(@PathVariable Integer pageNum, @PathVariable Integer pageSize, Order order){
        return orderService.getPageOrder(pageNum,pageSize,order);
    }
    @GetMapping("{orderId}")
    public R getOrderById(@PathVariable String orderId){
        return orderService.getOrderById(orderId);
    }
    @PutMapping("close/{orderId}")
    public R closeOrder(@PathVariable String orderId){
        return orderService.closeOrder(orderId);
    }
    @PutMapping("delivery")
    public R deliveryOrder(@RequestBody OrderDto orderDto){
        return orderService.deliveryOrder(orderDto);
    }
    @GetMapping("exp")
    public void exp(HttpServletResponse response) throws IOException {
        orderService.exp(response);
    }
}
